package com.shensi.appCollect.utils.yunHua;

import lombok.Builder;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.math.BigDecimal;

@Builder
public class YunHuaParam {

    String fmno;
    String carRefueling;
    String clientOrgCode;
    String lockFlag;
    String noticeUrl;
    String partnerCode;
    String payChannelId;
    String posOrderNo;
    String reqTime;
    BigDecimal txnAmt;
    String vsOrderNo;
    String   openId;
    String   userId;
    String   sign;
    String  txnDesc;


    public String getTxnDesc() {
        return txnDesc;
    }

    public void setTxnDesc(String txnDesc) {
        this.txnDesc = txnDesc;
    }



    String miniUrl;

    public String getMiniUrl() {
        return miniUrl;
    }

    public void setMiniUrl(String miniUrl) {
        this.miniUrl = miniUrl;
    }

    public String getCarRefueling() {
        return carRefueling;
    }

    public void setCarRefueling(String carRefueling) {
        this.carRefueling = carRefueling;
    }

    public String getClientOrgCode() {
        return clientOrgCode;
    }

    public void setClientOrgCode(String clientOrgCode) {
        this.clientOrgCode = clientOrgCode;
    }

    public String getLockFlag() {
        return lockFlag;
    }

    public void setLockFlag(String lockFlag) {
        this.lockFlag = lockFlag;
    }

    public String getNoticeUrl() {
        return noticeUrl;
    }

    public void setNoticeUrl(String noticeUrl) {
        this.noticeUrl = noticeUrl;
    }

    public String getPartnerCode() {
        return partnerCode;
    }

    public void setPartnerCode(String partnerCode) {
        this.partnerCode = partnerCode;
    }

    public String getPayChannelId() {
        return payChannelId;
    }

    public void setPayChannelId(String payChannelId) {
        this.payChannelId = payChannelId;
    }

    public String getPosOrderNo() {
        return posOrderNo;
    }

    public void setPosOrderNo(String posOrderNo) {
        this.posOrderNo = posOrderNo;
    }

    public String getReqTime() {
        return reqTime;
    }

    public void setReqTime(String reqTime) {
        this.reqTime = reqTime;
    }

    public BigDecimal getTxnAmt() {
        return txnAmt;
    }

    public void setTxnAmt(BigDecimal txnAmt) {
        this.txnAmt = txnAmt;
    }

    public String getVsOrderNo() {
        return vsOrderNo;
    }

    public void setVsOrderNo(String vsOrderNo) {
        this.vsOrderNo = vsOrderNo;
    }

    public String getOpenId() {
        return openId;
    }

    public void setOpenId(String openId) {
        this.openId = openId;
    }

    public String getFmno() {
        return fmno;
    }

    public void setFmno(String fmno) {
        this.fmno = fmno;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getSign() {
        return sign;
    }

    public void setSign(String sign) {
        this.sign = sign;
    }

    public  String toRequest(){
        String mm= "{\n" +
                "    \"carRefueling\": \""+getCarRefueling()+"\",\n" +
                "    \"clientOrgCode\": \""+getClientOrgCode()+"\",\n" +
                "    \"lockFlag\": \"lock\",\n" +
                "    \"noticeUrl\": \""+getNoticeUrl()+"\",\n" +
                "    \"openId\": \""+getOpenId()+"\",\n" +
                "    \"partnerCode\": \""+getPartnerCode()+"\",\n" +
                "    \"payChannelId\": \"wx_jsapi\",\n" +
                "    \"posOrderNo\": \""+getPosOrderNo()+"\",\n" +
                "    \"reqTime\": \""+getReqTime()+"\",\n" +
                "    \"sceneId\": \"oil\",\n" +
                "    \"txnAmt\": "+getTxnAmt()+",\n" +
                "    \"vsOrderNo\": \""+getVsOrderNo()+"\"\n" +
                "}";

        return  mm;
    }

    public  String toBeforeRequest(){
        String mm= "{\n" +
                "    \"fmno\": \""+getPartnerCode()+"\",\n" +
                "    \"clientOrderNo\": \""+getPosOrderNo()+"\",\n" +
                "    \"clientSerialNo\": \""+getPosOrderNo()+"\",\n" +
                "    \"userId\": \""+1111+"\",\n" +
                "    \"payChannel\": \"wx_minipay\",\n" +
                "    \"payParams\": \"{\\\"orgCode\\\":\\\""+getClientOrgCode()+"\\\",\\\"platform\\\":\\\"2\\\",\\\"notifyUrl\\\":\\\""+getNoticeUrl()+"\\\"}\",\n" +
                "    \"txnAmt\": "+getTxnAmt()+"\n" +
                "}";
        return  mm;
    }

    public  String toAfterSignRequest(){
        String clientOrgCode = getClientOrgCode();
        String mm;
        if(StringUtils.isEmpty(clientOrgCode)){
            if(getTxnDesc()==null){
                setTxnDesc("（未知）");
            }
            mm= "{\n" +
                    "    \"fmno\": \""+getPartnerCode()+"\",\n" +
                    "    \"clientOrderNo\": \""+getPosOrderNo()+"\",\n" +
                    "    \"clientSerialNo\": \""+getPosOrderNo()+"\",\n" +
                    "    \"userId\": \""+getUserId()+"\",\n" +
                    "    \"txnDesc\": \""+getTxnDesc()+"\",\n" +
                    "    \"payChannel\": \"wx_jsapi\",\n" +
                    "    \"payParams\": \"{\\\"oilTime\\\":\\\"2023-05-06 09:59:05\\\",\\\"platform\\\":\\\"2\\\",\\\"notifyUrl\\\":\\\""+getNoticeUrl()+"\\\"}\",\n" +
                    "    \"txnAmt\": "+getTxnAmt()+",\n" +
                    "    \"sign\": \""+getSign()+"\"\n" +
                    "}";
        }else {
            if(getTxnDesc()==null){
                setTxnDesc("（未知）");
            }
            mm= "{\n" +
                    "    \"fmno\": \""+getPartnerCode()+"\",\n" +
                    "    \"clientOrderNo\": \""+getPosOrderNo()+"\",\n" +
                    "    \"clientSerialNo\": \""+getPosOrderNo()+"\",\n" +
                    "    \"userId\": \""+getUserId()+"\",\n" +
                    "    \"txnDesc\": \""+getTxnDesc()+"\",\n" +
                    "    \"payChannel\": \"wx_jsapi\",\n" +
                    "    \"payParams\": \"{\\\"oilTime\\\":\\\"2023-05-06 09:59:05\\\",\\\"platform\\\":\\\"2\\\",\\\"notifyUrl\\\":\\\""+getNoticeUrl()+"\\\",\\\"orgCode\\\":\\\""+getClientOrgCode()+"\\\"}\",\n" +
                    "    \"txnAmt\": "+getTxnAmt()+",\n" +
                    "    \"sign\": \""+getSign()+"\"\n" +
                    "}";
        }

        return  mm;
    }

    public  String toAfterSignRequestWxMini(){
        String mm= "{\n" +
                "    \"fmno\": \""+getPartnerCode()+"\",\n" +
                "    \"clientOrderNo\": \""+getPosOrderNo()+"\",\n" +
                "    \"clientSerialNo\": \""+getPosOrderNo()+"\",\n" +
                "    \"userId\": \""+getUserId()+"\",\n" +
                "    \"txnDesc\": \""+"拉起支付"+"\",\n" +
//                "    \"payChannel\": \"wx_minipay\",\n" +
                "    \"payChannel\": \"wx_jsapi\",\n" +
                "    \"payParams\": \"{\\\"oilTime\\\":\\\"2023-05-06 09:59:05\\\",\\\"miniUrl\\\":\\\""+getMiniUrl()+"\\\",\\\"platform\\\":\\\"2\\\",\\\"notifyUrl\\\":\\\""+getNoticeUrl()+"\\\"}\",\n" +
                "    \"txnAmt\": "+getTxnAmt()+",\n" +
                "    \"sign\": \""+getSign()+"\"\n" +
                "}";
        return  mm;
    }

    public  String toAfterSignRequestAliMini(){
        String clientOrgCode = getClientOrgCode();
        String mm;
        if(StringUtils.isEmpty(clientOrgCode)){
            if(getTxnDesc()==null){
                setTxnDesc("（未知）");
            }
            mm= "{\n" +
                    "    \"fmno\": \""+getPartnerCode()+"\",\n" +
                    "    \"clientOrderNo\": \""+getPosOrderNo()+"\",\n" +
                    "    \"clientSerialNo\": \""+getPosOrderNo()+"\",\n" +
                    "    \"userId\": \""+getUserId()+"\",\n" +
                    "    \"txnDesc\": \""+getTxnDesc()+"\",\n" +
//                "    \"payChannel\": \"wx_minipay\",\n" +
                    "    \"payChannel\": \"ali_minipay\",\n" +
                    "    \"payMode\": \"2\",\n" +
                    "    \"payParams\": \"{\\\"oilTime\\\":\\\"2023-05-06 09:59:05\\\",\\\"openId\\\":\\\""+getOpenId()+"\\\",\\\"platform\\\":\\\"2\\\",\\\"notifyUrl\\\":\\\""+getNoticeUrl()+"\\\"}\",\n" +
                    "    \"txnAmt\": "+getTxnAmt()+",\n" +
                    "    \"sign\": \""+getSign()+"\"\n" +
                    "}";
        }else {
            if(getTxnDesc()==null){
                setTxnDesc("（未知）");
            }
            mm= "{\n" +
                    "    \"fmno\": \""+getPartnerCode()+"\",\n" +
                    "    \"clientOrderNo\": \""+getPosOrderNo()+"\",\n" +
                    "    \"clientSerialNo\": \""+getPosOrderNo()+"\",\n" +
                    "    \"userId\": \""+getUserId()+"\",\n" +
                    "    \"txnDesc\": \""+getTxnDesc()+"\",\n" +
//                "    \"payChannel\": \"wx_minipay\",\n" +
                    "    \"payChannel\": \"ali_minipay\",\n" +
                    "    \"payMode\": \"2\",\n" +
                    "    \"payParams\": \"{\\\"oilTime\\\":\\\"2023-05-06 09:59:05\\\",\\\"openId\\\":\\\""+getOpenId()+"\\\",\\\"platform\\\":\\\"2\\\",\\\"notifyUrl\\\":\\\""+getNoticeUrl()+"\\\",\\\"orgCode\\\":\\\""+getClientOrgCode()+"\\\"}\",\n" +
                    "    \"txnAmt\": "+getTxnAmt()+",\n" +
                    "    \"sign\": \""+getSign()+"\"\n" +
                    "}";
        }
        return  mm;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.JSON_STYLE)
                .append("carRefueling", getCarRefueling())
                .append("clientOrgCode",getClientOrgCode())
                .append("lockFlag", "lock")
                .append("noticeUrl", "https://ai.xailife.com/oil-ai-service1/oil-api/order/marketingPayCallback/callback")
                .append("openId", getOpenId())
                .append("partnerCode", getPartnerCode())
                .append("payChannelId", getPayChannelId())
                .append("posOrderNo", getPosOrderNo())
                .append("reqTime", getReqTime())
                .append("sceneId", "oil")
                .append("txnAmt", getTxnAmt())
                .append("vsOrderNo", getVsOrderNo())
                .toString();
    }

}
